#!/bin/bash
# Author: <xioooli@yahoo.com.cn>
# Licence: GPLv2
# 2009.08.13

read cmdline < /proc/cmdline
export cmdline

if ! [ "$1" = "start" -o "$1" = "restart" ]; then exit; fi 

for cmd in ${cmdline}; do
	case "${cmd}" in
		\#*) break ;; 
		*=*) export "${cmd}" ;;
		*) export "${cmd}=y" ;;
	esac
done

# handled prams, you can add your own below.
[ "$(which "$autoexec" 2>/dev/null)" ] && "$autoexec" 

# modify the inittab file for different dms such as gdm, kdm etc.
[ "$dm" ] && { 
	now="$(grep -m1 "^x:" /etc/inittab)"
	[ "$now" ] && sed -i "s|$now|#$now|" /etc/inittab
	line="$(grep -m1 "$dm" /etc/inittab)"
	[ "$line" ] && line1="${line/\#/}" && sed -i "s|$line|$line1|" /etc/inittab
}

# set locale

if [ x"$lang" != "x" -o x"$locale" != "x" ]; then
	LOCALE="$lang"
	[ "$LOCALE" ] || LOCALE="$locale"
	sed -i "s|LOCALE=.*$|LOCALE=\"$LOCALE\"|" /etc/rc.conf
fi
